package com.knight.jdk8.method.reference;

import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @Description: 方法引用
 * @author: knight
 * @Date: 2019-04-27 20:14
 */
public class MethodReferenceDemo {

    public static String test1(Supplier<String> supplier){
        return supplier.get()+"test";
    }

    public static String test2(String str, Function<String,String> function){
        return function.apply(str);
    }

    public static void main(String[] args) {
        Student student1 = new Student("zhangsan", 20);
        Student student2 = new Student("lisi", 40);
        Student student3 = new Student("wangwu", 90);
        Student student4 = new Student("zhaoliu", 80);
        Student student5 = new Student("sunqi", 70);

        List<Student> students = Arrays.asList(student1, student2, student3, student4, student5);
//        students.sort((studentParam1,studentParam2)->Student.compareStudentByName(studentParam1,studentParam2));
//        students.forEach(System.out::println);

//       students.sort(Student::compareStudentByAge);
//        students.forEach(System.out::println);

//        StudentComparator studentComparator = new StudentComparator();
//        students.sort(studentComparator::compareStudentByAge);
//        students.forEach(System.out::println);

/*        students.sort(Student::compareStudentByName);
        students.forEach(System.out::println);*/




        test1(String::new);

        test2("hello",String::new);


    }
}
